<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Title</title>
</head>
<body>
<div style="width: 80%;margin: 25px 10%;" class="container">
    <form class="layui-form" id="form" action="">
        <input type="hidden" name="id" id="id"/>
        <input type="hidden" name="cjId" id="cjId"/>
        <input type="hidden" name="xgId" id="xgId"/>
        <div class="layui-form-item">
            <label class="layui-form-label">所属公司</label>
            <div class="layui-input-block">
                <select name="gongsiId" id="gongsiId" lay-verify="required">
                    <option value="-1">请选择</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">用户账号</label>
            <div class="layui-input-block">
                <input type="text" name="userCode" id="userCode" placeholder="请输入账号" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item" id="yuan" style="display: none;">
            <label class="layui-form-label">原密码</label>
            <div class="layui-input-block">
                <input type="text" name="yuanpwd" id="yuanpwd" readonly placeholder="请输入原密码" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">用户密码</label>
            <div class="layui-input-block">
                <input type="text" name="password" id="password" placeholder="请输入密码" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">用户别名</label>
            <div class="layui-input-block">
                <input type="text" name="name" id="name"  placeholder="请输入用户别名" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">所属角色</label>
            <div class="layui-input-block">
                <select name="roleId" id="roleId" lay-verify="required">
                    <option value="-1">请选择</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-block">
                <input type="checkbox" value="1" lay-filter="zhuangtai" name="zhuangtai" id="zhuangtai" lay-skin="switch" lay-text="正常|禁用">
            </div>
        </div>
        <!--<div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>-->
    </form>
</div>
</body>
</html>
<script>
    //Demo
    layui.use('form', function(){
        var form = layui.form;
        //监听提交
        form.on('submit(formDemo)', function(data){
            layer.msg(JSON.stringify(data.field));
            return false;
        });
    });
</script>
<script>
    $.get(new Local().base_url+"/gongsi/show",function(data) {
        $.each(data.data, function () {
            var opt = $("<option></option>").appendTo("#gongsiId");
            opt.text(this.name).val(this.id);
        });
        layui.form.render();
    });
    $.get(new Local().base_url+"/role/all",function(data){
        $.each(data.data,function(){
            var opt=$("<option></option>").appendTo("#roleId");
            opt.text(this.name).val(this.id);
        });
        layui.form.render();
    });
</script>